//
//  OrderHaveAdressCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2018/1/10.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "OrderHaveAdressCell.h"

@interface OrderHaveAdressCell ()

@property (weak, nonatomic) IBOutlet UIView *bottomLineView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomMargin;

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *adressLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;

@end



@implementation OrderHaveAdressCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.bottomMargin.constant = 0;
    
    self.bottomMargin.constant = 0;
    
    self.nameLabel.font = MYFONT(16);
    
    self.adressLabel.font = MYFONT(14);
    
    self.phoneLabel.font = MYFONT(16);
    
    self.adressLabel.textColor = darkGray;
    
   
    
    [self drawDashLine:self.bottomLineView lineLength:2 lineSpacing:2 lineColor:[UIColor orangeColor]];

    // Initialization code
}

- (void)setModel:(AddressInfoModel *)model{
    _model = model;
    
    self.nameLabel.text = [NSString stringWithFormat:@"收货人: %@",_model.consigner];
    
    self.phoneLabel.text = [NSString stringWithFormat:@"手机号: %@",_model.mobile];
    
    NSString *temp = [NSString stringWithFormat:@"%@%@",_model.address_info,_model.address];
    
    if ([temp containsString:@"-"]) {
        
        temp = [temp stringByReplacingOccurrencesOfString:@"-" withString:@""];

    }else{
        
        temp = [temp stringByReplacingOccurrencesOfString:@"&nbsp;" withString:@""];

        
    }
    
    
    self.adressLabel.text = temp;
    
}






- (void)drawDashLine:(UIView *)lineView lineLength:(int)lineLength lineSpacing:(int)lineSpacing lineColor:(UIColor *)lineColor
{
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    [shapeLayer setBounds:lineView.bounds];
    [shapeLayer setPosition:CGPointMake(CGRectGetWidth(lineView.frame) / 2, CGRectGetHeight(lineView.frame))];
    [shapeLayer setFillColor:[UIColor clearColor].CGColor];
    //  设置虚线颜色为blackColor
    [shapeLayer setStrokeColor:lineColor.CGColor];
    //  设置虚线宽度
    [shapeLayer setLineWidth:CGRectGetHeight(lineView.frame)];
    [shapeLayer setLineJoin:kCALineJoinRound];
    //  设置线宽，线间距
    [shapeLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:lineLength], [NSNumber numberWithInt:lineSpacing], nil]];
    //  设置路径
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, 0, 0);
    CGPathAddLineToPoint(path, NULL, CGRectGetWidth(lineView.frame), 0);
    [shapeLayer setPath:path];
    CGPathRelease(path);
    //  把绘制好的虚线添加上来
    [lineView.layer addSublayer:shapeLayer];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
